package com.gdust.hzx.user.service.impl;

import com.gdust.hzx.model.entity.user.UserAddress;
import com.gdust.hzx.user.mapper.UserAddressMapper;
import com.gdust.hzx.user.service.UserAddressService;
import com.gdust.hzx.utils.AuthContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: UserAddressServiceImpl
 * Package: com.gdust.hzx.manager.service.impl
 * Description:
 *
 * @Author syun
 * @Create 2024/12/27 19:57
 * @Version 1.0
 */
@Service
public class UserAddressServiceImpl implements UserAddressService {
    //注入用户地址表
    //注入用户地址表的mapper
    @Autowired
    private UserAddressMapper userAddressMapper;


    /**
     * 获取用户地址
     *
     * @return
     */
    @Override
    public List<UserAddress> findUserAddressList() {
        //查询Redis中的用户id
        Long userId = AuthContextUtil.getUserInfo().getId();
        //自定义查询：根据Redis中获取的用户id获取用户地址
        List<UserAddress> userAddressList = userAddressMapper.findUserAddressList(userId);
        return userAddressList;
    }

    /**
     * //根据id获取收货地址信息
     * @param id
     * @return
     */
    @Override
    public UserAddress getUserAddress(Long id) {
        //根据id获取收货地址信息
        return userAddressMapper.getUserAddress(id);
    }
}
